﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows.Forms;

namespace XmlTest
{
    class XmlReadAndWrite
    {
        //XmlTextReader
        public static XmlTextReader getXmlTextReader(string filepath)
        {
            return new XmlTextReader(filepath);
        }

        public static List<string> getXmlElement(XmlTextReader objRd)
        {
            List<string> valuelist = new List<string>();
            while (objRd.Read())
            {
                //MessageBox.Show("1");
                if (objRd.NodeType == XmlNodeType.Element)
                {
                    //MessageBox.Show("2");
                    valuelist.Add(objRd.Name.ToString());
                }
            }
            return valuelist;
        }

        //XmlNodeReader
        public static XmlNodeList getXmlXmlNodeList(string filepath,string xpath)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(filepath);
            return doc.SelectNodes(xpath);
        }

        //XmlWriter


    }
}
